$OpenBSD: patch-algo_depsolver_ml,v 1.1.1.1 2014/10/25 17:05:14 chrisz Exp $

Changes for OPAM

--- algo/depsolver.ml.orig	Mon May 26 08:11:52 2014
+++ algo/depsolver.ml	Tue Sep  2 23:34:27 2014
@@ -369,9 +369,7 @@ let upgrade_constr universe name = 
       let p = List.hd(List.sort ~cmp:Cudf.(>%) pl) 
       in (name,Some(`Geq,p.Cudf.version))
 
-(** check if a cudf request is satisfiable. we do not care about
- * universe consistency . We try to install a dummy package *)
-let check_request ?cmd ?callback ?criteria ?(explain=false) (pre,universe,request) =
+let check_request_using ?call_solver ?callback ?criteria ?(explain=false) (pre,universe,request) =
   let intSolver ?(explain=false) universe request =
 
     let deps = 
@@ -413,19 +411,30 @@ let check_request ?cmd ?callback ?criteria ?(explain=f
       let criteria_array = Array.of_list (criteria_parser (Option.get criteria)) in
       minimize ?callback criteria_array universe dummy
   in
-  if Option.is_none cmd then begin
+  match call_solver with
+  | None ->
     let d = intSolver universe request in
     if Diagnostic.is_solution d then
       let is = Diagnostic.get_installationset d in
       Sat (Some pre,Cudf.load_universe is)
     else
       if explain then Unsat (Some d) else Unsat None
-  end else begin
-    let cmd = Option.get cmd in
-    let criteria = if Option.is_none criteria then "-removed,-new" else Option.get criteria in
-    try Sat(CudfSolver.execsolver cmd criteria (pre,universe,request)) with
+  | Some call_solver ->
+    try Sat(call_solver (pre,universe,request)) with
     |CudfSolver.Unsat when not explain -> Unsat None
     |CudfSolver.Unsat when explain -> Unsat (Some (intSolver ~explain universe request))
     |CudfSolver.Error s -> Error s
-  end
+
+(** check if a cudf request is satisfiable. we do not care about
+ * universe consistency . We try to install a dummy package *)
+let check_request ?cmd ?callback ?criteria ?explain cudf =
+  let call_solver =
+    match cmd with
+    | Some cmd ->
+        let criteria = Option.default "-removed,-new" criteria in
+        Some (CudfSolver.execsolver cmd criteria)
+    | None -> None
+  in
+  check_request_using ?call_solver ?callback ?explain cudf
+
 ;;
